<link href="/media/css/form.css" rel="stylesheet" type="text/css" />
<link href="/media/css/Title_white.css" rel="stylesheet" type="text/css" />

{% extends 'base.html' %}
{% block title %} - Project {{project.name}} edit mode{% endblock %}
{% block js %}
<script type="text/javascript" src="/site_media/js/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="/site_media/js/flowplayer-3.0.3.min.js"></script>
<link rel="stylesheet" href="/site_media/css/jquery.wysiwyg.css" type="text/css" />
<script type="text/javascript">
	$(function()
	{
		$('#wysiwyg').wysiwyg();
	});
	
	function select_artist_video(aid){
		$('#playVideo').html('');
		var url = "/project/{{project.id}}/artist/video/" + aid + "/";
		$.get(url, function(data) {
			$('#playVideo').html(data);
		});
				
		
		$('#playVideo').dialog("destroy");
		$('#playVideo').dialog( {
			title : 'Set artist video for this project',
			zIndex : 900,
			width : 800,
			height : 500,
			draggable : false,
			resizable : false,
			bgiframe : true,
			autoOpen : true,
			modal : true,
			buttons : {
				Close : function() {
					$(this).dialog("close");
					$("#player").html("");
				}
			}
		});
	}
	
	function play_video(video){ // 2011-02-06 By daoyu
		$('#playVideo').html("<div id='player'></div>");
		$('#playVideo').dialog("destroy");
		$('#playVideo').dialog( {
			title : 'Play Video',
			zIndex : 900,
			width : 700,
			height : 500,
			draggable : false,
			resizable : false,
			bgiframe : true,
			autoOpen : true,
			modal : true,
			buttons : {
				Close : function() {
					$(this).dialog("close");
					$("#player").html("");
				}
			}
		});
		
		var player = flowplayer("player", "/site_media/flowplayer-3.2.2.swf", {
			clip: {
				url: video,
				provider: 'h264streaming',
				autoPlay:true,
				autoBuffering:true,
				scaling: "scale"
			},
			plugins: {
				h264streaming: {
					url: '/site_media/flowplayer.pseudostreaming-3.2.2.swf'
				},
				controls: {
					url: '/site_media/flowplayer.controls-3.2.1.swf',
					play:true,
					stop:true,
					scrubber: true
				}
			}
		});	
	}
	
	function check_youtube(youtube_form){
		if (youtube_form.new_youtube.value==""){
			alert("Please input the youtube URL!");
			return false;
		}
		return true;
	}
	
	
	function show_youtube(youtube_show_form){
		if (youtube_show_form.show_youtube.value){
	
			return true;
		}
		show_youtube = false
		return true;
	}
	
	
	function check_email(email_form){
		if ( email_form.client_email.value == ""){
			alert("Please input the client's email!");
			return false;
		}
		
		return true;
	}
</script>
{% endblock %}
{% block content %}







<div id="content" style="position:absolute; top:20px; left:0px; width:auto; height:relative; background-color: #1A1A1A; layer-background-color: #1A1A1A; border: 1px none #000000;">




<table width="610">
	<tr><th>&nbsp;<br> Project info <button onclick="window.location.href ='/project/{{project.id}}/'" >View</button>
	</th></tr>
    
	<tr>
 	<form action="/project/{{project.id}}/change_name/" method="post">
	<td>Name:<br /><input name="project_name" type="text" value="{{project.name}}"/></td>
	<td>Brand:<br /><input name="project_brand" type="text" value="{{project.brand}}"/></td>
    <td>City:<br /><input name="project_city" type="text" value="{{project.city}}"/></td>       
    <td align="right" valign="bottom"><br/><input type="submit" value="Change"/></td>
    </form>
    </tr>
	<tr>
	<td colspan="4">Description:<br />
            <form method="post" action="/project/{{project.id}}/save/">
				<textarea name="description" {% if user.is_authenticated %}id="wysiwyg"{% endif %} rows="10" cols="82">							 				{{project.description}}
				</textarea>
				<input type="submit" value="Change">
			</form>
            </td>
		</tr>
      
	<tr>
	<th width="100">
			  <span class="Headline_player">&nbsp;<br>Artists</br></span>
	</th><td width="100"></td><td width="100"></td><td width="100"></td><td width="100"></td><td width="100"></td>
	</tr>
</table>


<table width="610">
        
        
        {% for pas in pass %}
  <tr class="tr_none">
		{% for pa in pas %}
		<td width="100" align="center">
        		{% if user.username == 'kth' %}
				<a onclick="return confirm('Delete this artist?');"
				href="/project/{{project.id}}/artist/{{pa.id}}/" title="Delete">
				<img src="/site_media/img/trash.gif">
		  </a>
				{% else %}
				{% if user.id == project.creator.id %}
				<a onclick="return confirm('Delete this artist?');"
				href="/project/{{project.id}}/artist/{{pa.id}}/">
				<img src="/site_media/img/trash.gif">
				</a>
				{% endif %}{% endif %}
                <br />
			<a href="javascript:;" title="View artist profile"
				onclick="select_artist_video({{pa.artist.id}});"
				>

				{% load zdy_filter %}
				{% if pa.video == '' %}				
					<img src="/{{pa.artist.get_profile.film|get_file_name}}.jpg" height="50">
				{% else %}
					<img src="/{{pa.video|get_file_name}}.jpg" height="50">				
				{% endif %}
				 <br/>

				{{pa.artist.first_name}}, {{pa.artist.last_name}} <br/>
				{{pa.artist.get_profile.role}}

		  </a>
	  </td>
		{% endfor %}
	 </tr>
	{% endfor %}
        
        
    </table>
       
    <table width="610">   
		
        
        	<tr>
			<td colspan="2">
<form action="/project/{{project.id}}/artist/" method="post" onsubmit="return check_user(this);">
        <select name="new_user"> <option value="" selected="true">-----</option>
            {% for art in artists %}
            <option value="{{art.id}}">{{art.first_name}}, {{art.last_name}} </option>
            {% endfor %}
            <input type="submit" value="Add"/>
        </select>
</form>

</td>
	  </tr>
      
<tr>
	<th colspan="2">
	<span class="Headline_player">&nbsp;<br>Attachments</br></span>
    </th>
</tr>  
</table>
    <a name="attachment" id="attachment"></a>    
<table width="610">

   <tr><td colspan="6">Attached files:</td></tr>
</table>

<table width="610">         
	{% for pfs in pfss %}
	<tr>
		{% for pf in pfs %}
		<td width="100" align="center" >      
	
			
			{% if user.username == 'kth' %}
			<a onclick="return confirm('Delete this file?');" href="/project/{{project.id}}/file/{{pf.id}}/"><img src="/site_media/img/trash.gif"></a>
			{% else %}
			{% if user.id == project.creator.id %}
			<a onclick="return confirm('Delete this file?');" href="/project/{{project.id}}/file/{{pf.id}}/"><img src="/site_media/img/trash.gif"></a>
			{% endif %}{% endif %}
            
            
            
           <input name="file_show" type="hidden" value=""/>
			{% if pf.show %}
			<a href="/project/{{project.id}}/file/hide/{{pf.id}}/">Hide</a>
			{% else %}
			<a href="/project/{{project.id}}/file/show/{{pf.id}}/">Show</a>
			{% endif %}
			<br/>
            
            <a href="javascript:;" onMouseDown="play_video('/{{pf.file}}');">
			{% load zdy_filter %} 
			<img height="50" src="/{{pf.file.name|get_project_file_img}}"><br>{{pf.title}}
			</a> 
			
		</td>
		{% endfor %}
	</tr>
	{% endfor %}
</table>
<div id="playVideo">
	<div id='player'></div>
</div>

<table width="610">
<form enctype="multipart/form-data" action="/project/{{project.id}}/addfile/" method="post" onsubmit="return check_(this);">


<tr><td colspan="2">New file: <br><input name="new_file" type="file" title="Add new file" size="15" />	<br/>
    
    Title:<br><input name="title" type="title" size="20"/></td>
    
  <td colspan="3">Description:<br><textarea name="txt" cols="40" rows="3" /></textarea></td>
  <td><input name="file_show" type="hidden" value=""/>  
    Show:<br><input name="file_show" type="checkbox"/><br/><br/>
    <input type="submit" value="Upload"/>
    </td>
    

  </tr>
  
</form>

</table>
<table width="610">
<tr><td colspan="6">Youtube links:</td></tr>
	 
	   {% for py in pys%}
	   <tr>
	     {% for p in py %}
	     <td width="100" align="center">
	       
	       <a href="/project/{{project.id}}/youtube/{{p.id}}/" onclick="return confirm('Delete this youtube URL?');">
           <img src="/site_media/img/trash.gif"></a>
	       
    	{% if p.show %}
		<a href='/project/{{project.id}}/youtube/hide/{{p.id}}/'>Hide</a>
     	{% else %}
		<a href='/project/{{project.id}}/youtube/show/{{p.id}}/'>Show</a>
      	{% endif %}     	
	    
           <br/>
	       
	       <a href="{{p.youtube}}" target="_new" alt="{{ p.youtube_text }}">
	         <img src="http://img.youtube.com/vi/{{p.youtube}}/0.jpg" height="50"/>
           </a><br />
	       
	       {% if p.youtube_title != "" %}
	       {{ p.youtube_title }}
	       {% endif %}
	       	       
         </td>
	     {% endfor %}
       </tr>
	   {% endfor %}  

</table>
<table width="610">
		<form action="/project/{{project.id}}/youtube/" method="post" onsubmit="return check_youtube(this);">
<tr><td>
    	YouTube link:
    	<br /><input name="new_youtube" type="text" size="20"/><br />
    
    	Title:<br><input name="you_title" type="text" size="20"/><input name="youtube_show" type="hidden" value=""/>
</td>
    
<td colspan="2">    
      Description:<br><textarea name="you_text" cols="40" rows="3" /></textarea></td>
<td>	<input name="youtube_show" type="hidden" value=""/> 
      	Show:<br><input name="youtube_show" type="checkbox"/><br />
  		<br /><input type="submit" value="Upload"/></br>
</td></tr>

</form>
      


<tr><th colspan="4"><span class="text"><br><br/>Client information</span></th></tr>
						<tr><td>Company:<br /><input name="first_name" type="text" value="{{project.client}}"/></td>
                        
      {% if client %} 
      <tr><td>
                        {% for client in clients %}
						<input type="radio" name="client" value="{{client.id}}"/>
						<a href="/user/{{client.id}}/" target="_blank">
							{{client.first_name}} 
						</a> <br>
						{% endfor %}
      </td></tr>
      {% endif %}
      <tr><td colspan="4">E-mail clients:</td></tr>
      <tr><td colspan="4">                        
    {% for pce in pces %}
       {{pce.title}} {{pce.name}} (<a href="mailto:{{pce.email}}">{{pce.email}}</a>) 
        <a href="/project/{{project.id}}/client_email/{{pce.id}}/" onclick="return confirm('Delete this client email?');">
            <img src="/site_media/img/trash.gif">
        </a>
        <br>
    {% endfor %}
    </td></tr>
        
    <form action="/project/{{project.id}}/add_client_email/" method="post" onsubmit="return check_email(this);">
     <tr><td>E-mail:<br /><input name="client_email" type="text" size="20" /></td>
     <td>Name:<br /><input name="client_name" type="text" size="20" /> </td>
     <td>Title:<br /><input name="client_title" type="text" size="15" /></td>
     <td align="right"><br><input type="submit" value="Add" /></td></tr>
     </form>
    
<tr><td align="left"><FORM><INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"> </FORM></td></td>                     
</table>
		  </th>
		</tr>
	</div>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
{% endblock %}